package com.sinoglobal.dumping;

import android.content.Context;
import android.content.Intent;

import com.sinoglobal.dumping.base.Dumpling_SharedPreferenceUtil;
import com.sinoglobal.dumping.base.Dumpling_SinoConstans;
import com.sinoglobal.dumping.bean.Dumpling_UserInfoVo;
import com.sinoglobal.dumping.util.DumplingCache;

import static com.sinoglobal.dumping.base.Dumpling_SinoConstans.*;

/**
 * Created by KeZhuang on 2015/11/17.
 */
public class DumplingInterface {
    public static void logout(Context context){
        DumplingCache cache = new DumplingCache(context);
        Dumpling_SinoConstans.USER_ID="";
        Dumpling_SinoConstans.USER_NAME="";
        cache.put(DUMPLING_MARK_LOGIN,LOGIN_STATE_QUIT);
        Dumpling_SharedPreferenceUtil.removeUserData(context);
        int dumplingCode = (Integer) cache.get(DUMPLING_CODE,0);
        if(dumplingCode==0 || dumplingCode==SUCCESS_CODE){
            cache.clear();
        }
    }
    public static void login(Context context , String userName ,String userId){
        Dumpling_UserInfoVo infoVo = new Dumpling_UserInfoVo();
        infoVo.setUserName(userName);
        infoVo.setId(userId);
        Intent i = new Intent();
        i.putExtra("code","");
        i.putExtra("userInfo",infoVo);
        i.setAction(DUMPLING_GETMONEY_ACTION);
        context.sendBroadcast(i);
    }
}
